#pragma once
#include "Weapon.h"
#include "ObjectDatabase.h"
#include "Util.h"

class Ammo;

class RangedWeapon : public Weapon {
protected:
	RangedWeaponPrefix m_prefix;
	RangedWeaponSuffix m_suffix;
	AmmoType m_ammoType;
	int m_range;
	int m_defaultRange;
	int m_maxAmmo;
	int m_currentAmmo;
	void calculateStats(const RangedWeaponInfo& info, bool defaultsOnly = false);
	bool isEnchanted() const;
public:
	RangedWeapon(RangedWeaponType weaponType, RangedWeaponPrefix prefix = RWP_NONE, RangedWeaponSuffix suffix = RWS_OF_NONE, bool m_highQuality = false, float startAmmo = 0.0f);
	RangedWeapon(std::ifstream& file);
	~RangedWeapon();
	void render(float x, float y);
	void logDetails(TextLog& log) const;
	RangedWeaponPrefix getPrefix() const;
	RangedWeaponSuffix getSuffix() const;
	GripType getGripType() const;
	int getAccuracy() const;
	int getSpeed() const;
	int getRangedAccuracy() const;
	int getRangedSpeed() const;
	int getRange() const;
	AmmoType getAmmoType() const;
	std::string getItemName(int mod = 0) const;
	void save(std::ofstream& file) const;
	int getRandomDamage() const;
	int getRandomRangedDamage() const;
	bool reload(Ammo* ammo);
	int getCurrentAmmo() const;
};

inline RangedWeaponPrefix RangedWeapon::getPrefix() const {return m_prefix;}
inline RangedWeaponSuffix RangedWeapon::getSuffix() const {return m_suffix;}
inline GripType RangedWeapon::getGripType() const {return m_gripType;}
inline int RangedWeapon::getAccuracy() const {return 0;}
inline int RangedWeapon::getSpeed() const {return 100;}
inline int RangedWeapon::getRandomDamage() const {return rand_plus_one(4);}
inline int RangedWeapon::getRangedAccuracy() const {return m_accuracy;}
inline int RangedWeapon::getRangedSpeed() const {return m_speed;}
inline int RangedWeapon::getRandomRangedDamage() const {return getRandomDiceDamage();}
inline int RangedWeapon::getRange() const {return m_range;}
inline AmmoType RangedWeapon::getAmmoType() const {return m_ammoType;}
inline int RangedWeapon::getCurrentAmmo() const {return m_currentAmmo;}
